﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.Storage;

namespace Eu.Xquirrel.Networking.Http.Offline
{
    public class HTTPLaunchObjectsModel
    {
        public enum Context
        {
            StorageFile,
            StringFile
        }

        public Context ContextType;
        public StorageFolder StorageFolder;
        public StorageFile StorageFile;
        public string File;


        /// <summary>
        /// Determines if a folder represented by a StorageFolder object, is
        /// a child of the Pictures library.
        /// </summary>
        /// <param name="folder">The StorageFolder object that identifies the chosen folder</param>
        /// <returns>True if the folder is a child of Pictures, else false.</returns>
        public static bool IsFolderChildOfPicturesLibrary(StorageFolder folder)
        {
            string[] myfolder = folder.Path.Replace("\\\\", "\\").Split('\\');

            bool pictures = false;
            string rootpath = string.Empty;
            for (int x = 0; x < myfolder.Length; x++)
            {
                if (pictures)
                {
                    rootpath += "\\" + myfolder[x];
                }
                if (myfolder[x].ToLower() == "pictures")
                {
                    pictures = true;
                }
            }

            return pictures;
        }

        public static bool IsFileInPathOfServerRoot(StorageFolder folder, StorageFile file)
        {
            return folder.Path == file.Path.Substring(0, folder.Path.Length);
        }
    }
}
